# -*- encoding:utf-8 -*-
"""
@作者：ven
@文件名：login.py
@时间：2024-11-11  17:50
@文档说明:登录
"""
import requests

from com.baseApi import BaseAPI


class Login(BaseAPI):
    def login(self, username='root', isRoot=False):
        if isRoot:
            # payload = {"authType": "PC",
            #            "username": username,
            #            "password": "G2+MS6F4nQJ9nnOGkkjGgKxLaiu38uoTEhIQ/OVpFbttvrOWr/KxhVuMv20+Fw3Tsaw2t/pFvnIBUg7uYpFPGoDnmHf2tPZTt0bIvDxjkEfltw20J62P6HhqXvChHzYvohHadGmXt6YKUA6+zsG/4ZH/Ocnq20KEuiFHYllwGiw=",
            #            # 这个密码是123456 "password":"k7QU3Dz7bTm60p0l7sWbIVSc7wA8ArEsvBU1duO04Gxvn1IMB39o3gUdLdS41+MOVx9ZrmozqjiFdaUGYoGmH6rlg8I2A+a58AQ7WWitjTW+PJGQdnWD+QKFD6Ab6gndZ/0YwNIl2iHnG0ajOZ1h/NgEXe0ICrSOYN58cjbEKpo="
            #            }
            payload = {"authType": "PC",
                       "username": "root",
                       "password": "UM+jtiiRsTA00LiHgVDLgmXZ2dulpAg1Opga4prVckrkbNjmnv8qBKe3MdaIk+HQIVlVZk6ena34hkbF3sRBwQeljc62AghyFpXiTp18HuR8XAJq+ndx+myJttEY9jRmouIUWahVsfHECEt9oZ033NqJF6TEi4FSK7eqohRM4zo="}

            res = self.request_send(json=payload, params={"code": "undefined", "uuid": "undefined"})

            return res.json()['data']['token']['accessToken']
            # return res.json()
        else:
            payload = {"authType": "PC",
                       "username": username,
                       "password": "UfE0BEZr6z247RjriwkXVPZ3S0cNPOrpueW7pmebbDWBBjmSdBMc5c3ajdTy8sHEaa+ieVJTxX/d7QESeFfvA2D+6ReWflxYDNUV81BpBhwsf+b4NO+1YUrDzlWrOx3iVrzqaZO1uXEBfPQRJ9aaJB/48UHDiuQv1i5679FcOkI="}
            # "password": "ivqyXj/jdgl5GGJFSkGrMUnb0FS7fhgPnPiRBNKpwb/MIpNB56fBluEoS7SBMmPVNvR/Fars5IWY0nrbJOhIPakEP7ABJXYU9eftGVBD/DZSD7B6x7gzXP1hA1Zbg2NkD+2LPCTVoABZCiCL4b7ADiGoQKzFSHq8eleW/IPh53o="}
            res = self.request_send(json=payload)
            # return res.json()['data']['token']['accessToken']
            return res.json()['data']['token']['accessToken']


if __name__ == '__main__':
    # 非管理员账号
    # payload= {"authType": "PC",
    #           "username": "755",
    #           "password": "ivqyXj/jdgl5GGJFSkGrMUnb0FS7fhgPnPiRBNKpwb/MIpNB56fBluEoS7SBMmPVNvR/Fars5IWY0nrbJOhIPakEP7ABJXYU9eftGVBD/DZSD7B6x7gzXP1hA1Zbg2NkD+2LPCTVoABZCiCL4b7ADiGoQKzFSHq8eleW/IPh53o="}
    # token = Login().login(username="root",isRoot=True)
    # print(token)

    token = Login().login(username="root", isRoot=True)
    print(token)
